import time

from selenium import webdriver
from selenium.webdriver import Keys
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.get("https://demo.crudapi.cn/crudapi/login")

driver.maximize_window()


def elements_conf():
    return {
        "user_input": "q-field__native.q-placeholder",
        "password_input": '[type="password"]',
        "login_btn": "q-btn__content.text-center.col.items-center.q-anchor--skip.justify-center.row"
    }


def input_all_delete(input_path):
    input_path.send_keys(Keys.CONTROL, 'a')
    input_path.send_keys(Keys.DELETE)



def login():
    User_input = driver.find_element(By.CLASS_NAME, elements_conf()["user_input"])
    Password_input = driver.find_element(By.CSS_SELECTOR, elements_conf()["password_input"])
    Login_btn = driver.find_element(By.CLASS_NAME, elements_conf()["login_btn"])

    input_all_delete(User_input)
    User_input.send_keys('superadmin')

    input_all_delete(Password_input)
    Password_input.send_keys('1234567890')

    Login_btn.click()


login()

time.sleep(3)
driver.close()
